package com.ruoyi.project.learn.sscl.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.learn.sscl.domain.DjRealTimeMaterial;
import com.ruoyi.project.learn.sscl.service.IDjRealTimeMaterialService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 实时材料Controller
 * 
 * @author ruoyi
 * @date 2025-09-17
 */
@Controller
@RequestMapping("/learn/sscl")
public class DjRealTimeMaterialController extends BaseController
{
    private String prefix = "learn/sscl";

    @Autowired
    private IDjRealTimeMaterialService djRealTimeMaterialService;

    @RequiresPermissions("learn:sscl:view")
    @GetMapping()
    public String sscl()
    {
        return prefix + "/sscl";
    }

    /**
     * 查询实时材料列表
     */
    @RequiresPermissions("learn:sscl:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DjRealTimeMaterial djRealTimeMaterial)
    {
        startPage();
        List<DjRealTimeMaterial> list = djRealTimeMaterialService.selectDjRealTimeMaterialList(djRealTimeMaterial);
        return getDataTable(list);
    }

    /**
     * 导出实时材料列表
     */
    @RequiresPermissions("learn:sscl:export")
    @Log(title = "实时材料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DjRealTimeMaterial djRealTimeMaterial)
    {
        List<DjRealTimeMaterial> list = djRealTimeMaterialService.selectDjRealTimeMaterialList(djRealTimeMaterial);
        ExcelUtil<DjRealTimeMaterial> util = new ExcelUtil<DjRealTimeMaterial>(DjRealTimeMaterial.class);
        return util.exportExcel(list, "实时材料数据");
    }

    /**
     * 新增实时材料
     */
    @RequiresPermissions("learn:sscl:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存实时材料
     */
    @RequiresPermissions("learn:sscl:add")
    @Log(title = "实时材料", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DjRealTimeMaterial djRealTimeMaterial)
    {
        return toAjax(djRealTimeMaterialService.insertDjRealTimeMaterial(djRealTimeMaterial));
    }

    /**
     * 修改实时材料
     */
    @RequiresPermissions("learn:sscl:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        DjRealTimeMaterial djRealTimeMaterial = djRealTimeMaterialService.selectDjRealTimeMaterialById(id);
        mmap.put("djRealTimeMaterial", djRealTimeMaterial);
        return prefix + "/edit";
    }

    /**
     * 修改保存实时材料
     */
    @RequiresPermissions("learn:sscl:edit")
    @Log(title = "实时材料", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DjRealTimeMaterial djRealTimeMaterial)
    {
        return toAjax(djRealTimeMaterialService.updateDjRealTimeMaterial(djRealTimeMaterial));
    }

    /**
     * 删除实时材料
     */
    @RequiresPermissions("learn:sscl:remove")
    @Log(title = "实时材料", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(djRealTimeMaterialService.deleteDjRealTimeMaterialByIds(ids));
    }
}
